package com.dqyt.khjc.controller;

import com.dqyt.khjc.bean.ResultMsg;
import com.dqyt.khjc.service.SwitchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 各种开关设置
 */
@RestController
public class SwitchController {

    @Autowired
    private SwitchService switchService;




    /**
     * 获取所有开关
     * @return
     */
    @RequestMapping(value = "/api/getSwitchList", method = {RequestMethod.POST})
    public ResultMsg getSwitchList(HttpServletRequest request){
        ResultMsg resultMsg = switchService.getSwitchList(request);
        return resultMsg;
    }


    /**
     * 修改开关的状态
     * @return
     */
    @RequestMapping(value = "/api/updateSwitchById", method = {RequestMethod.POST})
    public ResultMsg updateSwitchById(HttpServletRequest request, int id, int swState){
        ResultMsg resultMsg = switchService.updateSwitchById(request,id,swState);
        return resultMsg;
    }


    /**
     * 修改开关的状态
     * @return
     */
    @RequestMapping(value = "/api/getJydwsqh", method = {RequestMethod.POST})
    public ResultMsg getJydwsqh(HttpServletRequest request){
        ResultMsg resultMsg = switchService.getJydwsqh(request);
        return resultMsg;
    }


    /**
     * 修改开关的状态
     * @return
     */
    @RequestMapping(value = "/api/updateJydwsqh", method = {RequestMethod.POST})
    public ResultMsg updateJydwsqh(HttpServletRequest request,String mz_jydwsqh,String qp_jydwsqh,String ylb_jydwsqh){
        ResultMsg resultMsg = switchService.updateJydwsqh(request,mz_jydwsqh,qp_jydwsqh,ylb_jydwsqh);
        return resultMsg;
    }




}
